package com.tianji.learning.controller;


import com.tianji.api.dto.course.CourseSimpleInfoDTO;
import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author 邓明明
 * @since 2023-04-24
 */
@RestController
@RequestMapping("/learning-records")
@Api(tags = "学习记录的相关接口")
public class LearningRecordController {

    @Resource
    private ILearningRecordService iLearningRecordService;

    @ApiOperation("查询指定课程的学习记录")
    @GetMapping("/course/{courseId}")
    public LearningLessonDTO queryLearningRecordByCourse(
            @ApiParam(value = "课程id",example = "2") @PathVariable("courseId") Long courseId){
        return iLearningRecordService.queryLearningRecordByCourse(courseId);
    }

    @ApiOperation("提交学习记录")
    @PostMapping
    public void addLearningRecord(@RequestBody LearningRecordFormDTO recordFormDTO) {
        iLearningRecordService.addLearningRecord(recordFormDTO);
    }
}
